import os
import cv2
import numpy as np

dir_old = 'D:/Datasets/gesture_static_number/'
dir_new_clean = 'D:/Datasets/GestureNumber/train_clean/'

if os.path.exists(dir_new_clean) == False:
	os.mkdir(dir_new_clean)

lst_imgs_old = os.listdir(dir_old)
for img_file in lst_imgs_old:
	img = cv2.imread(dir_old + img_file, cv2.IMREAD_GRAYSCALE)
	img = cv2.resize(img, (32, 32), interpolation = cv2.INTER_CUBIC)
	file_name = img_file.split('/')[-1]
	cv2.imwrite(dir_new_clean + file_name, img)
	img2 = np.rot90(img)
	file_name2 = file_name.split('.')[0] + '_r' + '.jpg'
	cv2.imwrite(dir_new_clean + file_name2, img2)
